#pragma once

#include <algorithm/analytical_model/algorithm/cuda/inter_op/Data.h>
#include <vector>
#include <vector_types.h>

namespace solar::cuda
{
    class RectangleHeliostat
    {

        public:
            __host__ __device__ RectangleHeliostat()
                : sub_helio_size_(1),
                  h_local_centers(nullptr), h_local_normals(nullptr)
            {
            }
            __host__ __device__ ~RectangleHeliostat() = default;
            void setNormalAndRotate(const float3& focus_center, const float3& sunray_dir);
            auto getDiscreteMicroHelioOriginsAndNormals(float3*& d_microhelio_centers,
                                                        float3*& d_microhelio_normals) const -> int;
            void getSubHeliostatVertices(std::vector<float3>&) const;
            [[nodiscard]] auto getImagePlaneAxis() const -> std::tuple<float3, float3, float3>;

            int helio_depth_ = 0.003;
            float reflect_;
            float refract_ = 1.5;
            float3 pos_;
            float3 size_;
            float3 vertices_[4];
            float3 normal_;
            int2 row_col_;
            float2 gap_;
            inter_op::SubCenterType sub_center_type_{};
            float pixel_length_;
            int sub_helio_size_;
            int belonging_grid_id_;
            float3* h_local_centers;
            float3* h_local_normals;
            float3 focus_center_;

        private:
            void setWorldVertex();
            void setNormal(const float3& focus_center, const float3& sunray_dir);
    };
} // namespace solar::cuda
